package Model;

import java.util.ArrayList;

public class BusinessRule {

	private String type;
	private int businessRuleID;
	private String businessRuleName;
	private String errorMessage;
	
	private String onTable;
	private String onColumn;
	private String operator;
	private ArrayList<Constraint> constrains;
	
	private String triggerWhen;
	private String[] triggerAction;
	private String triggerWhere;
	
	public BusinessRule(int id, String name, String error, String t, String c, String op, ArrayList<Constraint> constrain){
		businessRuleID = id;
		businessRuleName = name;
		errorMessage = error;
		onTable = t;
		onColumn = c;
		operator = op;
		constrains = constrain;
		triggerWhen = "";
		triggerAction = null;
		triggerWhere = "";		
	}
	
	public BusinessRule(int id, String ty, String name, String error, String t, String c, String op, ArrayList<Constraint> constrain){
		businessRuleID = id;
		businessRuleName = name;
		errorMessage = error;
		onTable = t;
		onColumn = c;
		operator = op;
		constrains = constrain;
		triggerWhen = "";
		triggerAction = null;
		triggerWhere = "";	
		type = ty;
	}
	
	public void setTrigger(String when, String[] action, String where){
		triggerWhen = when;
		triggerAction = action;
		triggerWhere = where;
	}
	
	public int getBusinessRuleID(){return businessRuleID;}
	public String getBusinessRuleName(){return businessRuleName;}
	public String getErrorMessage(){return errorMessage;}
	public String getOperator(){return operator;}
	public ArrayList<Constraint> getConstrains(){return constrains;}
	public String getTriggerWhen(){return triggerWhen;}
	public String[] getTriggerActions(){return triggerAction;}
	public String getTriggerWhere(){return triggerWhere;}
	public String getTable(){return onTable;}
	public String getColumn(){return onColumn;}
	public String getType(){return type;}
	
	public String toString(){
		return businessRuleID + " : " + businessRuleName;
	}
}
